package com.xyhuo.leetcode;

import com.xyhuo.leetcode.common.TreeNode;

public class CountNodes {

    public int countNodes(TreeNode root) {
        cal(root);
        return count;
    }


    private int count = 0;

    private void cal(TreeNode root) {
        if (root == null) {
            return;
        }
        count++;
        cal(root.left);
        cal(root.right);
    }
}
